]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-box-layout: Pass correct allocation box to layout manager
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Fri, 24 Aug 2018 00:41:00 +0000 (21:41 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 9 Oct 2018 01:42:24 +0000 (22:42 -0300)
StBoxLayout implements StScrollable, which, semantically, means that
the StBoxLayout size may not match the minimum size reported by the
layout manager. In this specific case, the layout manager by is a
ClutterBoxLayout by default. For example:

        +--------------+
        |   Viewport   |
 +------+--------------+-----------------+
 |      |              |                 |
 |      |              |     Content     |
 |      |              |                 |
 +------+--------------+-----------------+
        |              |
        +--------------+

So, assuming that:

 - ContentSize = the minimum size of the content;
 - ViewportSize = the allocated size of the viewport;

When allocating StBoxLayout, it must assume ViewportSize, but must
pass ContentSize to the layout manager. That way, the children of
StBoxLayout are correctly placed within it, even if it's bigger than
ViewportSize.

And here's the problem: right now, StBoxLayout assumes ViewportSize
AND also passes it to layout manager. Commit 77c4c6b6d specifically
exposed this bug by relying entirely on StBoxLayout to arrange the
app and window icons.

Fix that by using ViewportSize to allocate StBoxLayout itself, but
passing ContentSize to the layout manager.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153

src/st/st-box-layout.c

index 3acb15c4039cb5f05aac176f4a8df29b73df1f9c..1b7127e69faaf794e4a34df1a66d67a985fbb0bd 100644 (file)
@@ -282,13 +282,12 @@ st_box_layout_allocate (ClutterActor          *actor,
   StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
   ClutterLayoutManager *layout = clutter_actor_get_layout_manager (actor);
+  ClutterActorBox viewport_content_box;
   ClutterActorBox content_box;
   gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height;
 
-  CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->allocate (actor, box, flags);
-
-  st_theme_node_get_content_box (theme_node, box, &content_box);
-  clutter_actor_box_get_size (&content_box, &avail_width, &avail_height);
+  st_theme_node_get_content_box (theme_node, box, &viewport_content_box);
+  clutter_actor_box_get_size (&viewport_content_box, &avail_width, &avail_height);
 
   clutter_layout_manager_get_preferred_width (layout, CLUTTER_CONTAINER (actor),
                                               avail_height,
@@ -297,6 +296,18 @@ st_box_layout_allocate (ClutterActor          *actor,
                                                MAX (avail_width, min_width),
                                                &min_height, &natural_height);
 
+  /* Because StBoxLayout implements StScrollable, the allocation box passed here
+   * may not match the minimum sizes reported by the layout manager. When that
+   * happens, the content box needs to be adjusted to match the reported minimum
+   * sizes before being passed to clutter_layout_manager_allocate() */
+  clutter_actor_set_allocation (actor, box, flags);
+
+  content_box = viewport_content_box;
+  content_box.x2 += MAX (0, min_width - avail_width);
+  content_box.y2 += MAX (0, min_height - avail_height);
+
+  clutter_layout_manager_allocate (layout, CLUTTER_CONTAINER (actor),
+                                   &content_box, flags);
 
   /* update adjustments for scrolling */
   if (priv->vadjustment)